--module TestLoanManager where

import DBS
import Loan
import Date
import LoanManager
import FilmManager
import Film
import Client
import ClientManager

d1, d2, d3, d4 :: DBS

{- Films -}
f1 = Film 1 ("Star Wars", 2000, "George Lucas", "science-fiction", Available, "kolejna czesc sagi")
f2 = Film 2 ("Forrest Gump", 1994, "Robert Zemeckis", "fabularny", Lost, "Oscarowa rola T. Hanksa")
f3 = Film 3 ("Mis", 1972, "Stanislaw Bareja", "komedia", Loaned, "film demaskujacy absurdy PRL-u lat 70.-tych")
f4 = Film 4 ("Kapitan Sowa na tropie", 1965, "Stanislaw Bareja", "kryminalny", Available, "pierwszy polski serial kryminalny")
d1 = insertFilm (getFilmInfo f1) empty
d2 = insertFilm (getFilmInfo f2) d1
d3 = insertFilm (getFilmInfo f3) d2
d4 = insertFilm (getFilmInfo f4) d3

{- Clients -}
c1 = Client 1 ("Adam", "Kowalski", "12.06.1981", "Pl. Politechniki 1 Warszawa")
c2 = Client 2 ("Amon", "Re", "29.02.-2700", "Giza")
c3 = Client 3 ("Zygmunt", "III Waza", "20.06.1566", "Szwedzki zamek Gripsholm")
c4 = Client 4 ("Obi-wan", "Kenobi", "2.01.19981", "Tatooine")
d5 = insertClient (getClientInfo c1) d4
d6 = insertClient (getClientInfo c2) d5
d7 = insertClient (getClientInfo c3) d6
d8 = insertClient (getClientInfo c4) d7

{- Loans -}
l1 = Loan 1 (1, 1, (Date 1 5 2010), (Date 1 6 2010), Empty)
l2 = Loan 2 (1, 2, (Date 2 5 2010), (Date 2 6 2010), Empty)
l3 = Loan 3 (2, 3, (Date 3 5 2010), (Date 3 6 2010), Empty)
l4 = Loan 4 (4, 4, (Date 3 5 2010), (Date 3 6 2010), Empty)
l5 = Loan 5 (5, 4, (Date 3 5 2010), (Date 3 6 2010), Empty)

dl1 = insertLoan (getClientId l1) (getFilmId l1) (getDateLoaned l1) (getDateObliged l1) d8
-- l1 dodany
dl2 = insertLoan (getClientId l2) (getFilmId l2) (getDateLoaned l2) (getDateObliged l2) d8
-- Nothing - film jest Lost
--dl3 = insertLoan (getClientId l3) (getFilmId l3) (getDateLoaned l3) (getDateObliged l3) d8
-- l3 nie dodany - film jest (film z takim id) juz wypozyczony
dl4 = insertLoan (getClientId l4) (getFilmId l4) (getDateLoaned l4) (getDateObliged l4) d8
-- l4 dodany
dl5 = insertLoan (getClientId l5) (getFilmId l5) (getDateLoaned l5) (getDateObliged l5) d8
-- Nothing - nie ma takiego klienta

du1 = case dl1 of
	Left d	-> updateLoan 1 1 3 (Date 6 6 2010) d
-- "nr parametru spoza zakresu"
du2 = case dl1 of
	Left d	-> updateLoan 1 1 2 (Date 6 6 2010) d
-- zmienil

du3 = case dl1 of
	Left d	-> updateLoan 1 2 1 (Date 30 4 2010) d
-- Nothing - nie ma Loan z takim id


g1 = case dl1 of
	Left d	-> getByPeriod (Date 1 1 2001) (Date 1 1 2020) d


r1 = case dl1 of
	Left d	-> returnLoan 1 (Date 6 6 2010) d
-- zmienione
r2 = case dl1 of
	Left d	-> returnLoan 2 (Date 6 6 2010) d
-- "ten film nie byl nigdy wypozyczony"
r3 = case dl1 of
	Left d	-> returnLoan 5 (Date 6 6 2010) d
-- "nie ma filmu o takim id"
